home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / mus / misc / RaveScope.lha / RaveScope / Developer / delirave.s next >
Encoding:
Text File  |  1998-09-22  |  38.2 KB  |  1,008 lines

  1. ;-------T-------T-------T-------T-------T-------T-------T-------T-------T-------T-------T----x
  2. ;Labels (16)    Instructions (48)                               Comments (30++)
  3. ;              $VER: DeliRave 1.0
  4. ;        Started: 980216
  5. ;       Location: Waratah.au
  6. ;      Last drunk: 10 days ago
  7. ;    Last stoned: Today (NM)
  8. ;           Mood: Homesick
  9. ;     Todays wishes: 1> LAG 2> Return to Sweden
  10. ;           Changed: 980217, 980218, 980219, 980222, 980223, 980224, 980225
  11. ;        Changed: 980302, 980303, 980304, 980306, 980308, 980310, 980313
  12. ;        Changed: 980314, 980315, 980324, 980410, 980411, 980413, 980906
  13.  
  14. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  15. *                                                   ...     *
  16. *    ::::::.::::::. :::::::.   .::  ::::::. .::::.  :::     *
  17. *    .::.::'.::..:: .::..::' ...`::..::..'' .::.    `'      *
  18. *    :::    :::: ::::::: `::.::::::'::::.::.::::::' :::     *
  19. *    ..................................................    *
  20. *                                                               *
  21. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  22.  
  23. ; Captain's log...
  24. ;
  25. ; 980216:2125    (001) Got this source from Peter Kunath yesterday. Managed to assemble it today,
  26. ;        and I'm right now trying to figure out how to use it, commenting it as much
  27. ;        as possible.
  28. ; 980216:2317    (002) I have decided how to implement the Ravescope to delitracker. When the
  29. ;        genie (DeliRave) is started, it will first FindTask("RaveScope"). If it is
  30. ;        found everything is fine, they will establish a connection where DeliRave is
  31. ;        feeding data to the RaveScope. If it is not found, DeliRave will try to load
  32. ;        its config (DeliRave.config, amongst the other delitracker genie configs).
  33. ;        The config will, amongst other things, contain the path to the RaveScope
  34. ;        executable. If the config was not found a default path will be used. DeliRave
  35. ;        tries to start the RaveScope, if it succeeds everything is fine, if not, some
  36. ;        sort of action will be taken.
  37. ;        To configure the genie, select the Config button in the list of Genies. This
  38. ;        will pop up a window with a single button "Select ravescope path". The window
  39. ;        will have the standard delitracker menus, i.e I'll use Deliriums routines here.
  40. ;        ** I'm now storing dr_Data into the TC_Userdata field of the Delirave's task.
  41. ;        dr_Data will be DeliRave's global data-structure, eventually.
  42. ; 980216:2357    (003) I appear to have removed the level 3 interrupt routines, the timer-device
  43. ;        routines and related routines, without causing any damage...
  44. ; 980217:0018    (004) Removed some scope and window display routines.
  45. ; 980217:0028    (005) Removed routines (and structures) related to the scope's rastport & bitmap.
  46. ; 980217:1537    (006) Changed some global names to use the prefix dr_. Aligned source to start
  47. ;        on the second column.
  48. ; 980217:1653    (007) Added dr_Init, to be called from dr_Begin and dr_Config. It gets the
  49. ;        library bases from DeliBase, opens utility library (if not open already) and
  50. ;        stores a ptr to itself (thistask) plus stores the address to dr_Data in the
  51. ;        TC_Userdata field (if this has not been done already). I'm going to make all
  52. ;        the routines here get/store the local data relative to a5=dr_Data.
  53. ; 980217:1816    (008) Removed the appear and disappear routines temporarily. Managed to move the
  54. ;        window open routine to the Config part. So when config is pressed, the old
  55. ;        window shows up. It waits for CTRL-C, window messages and delitracker messages.
  56. ;        These delitracker messages seems to be caused by the buttons in the Geniewindow.
  57. ;        Some, or all, messages prompts the routine to jump to another routine. So, the
  58. ;        Begin routine jumps to the Config routine... when in the config, it seems that
  59. ;        there will be no more delimessages, because the pointer turns to a wait-pointer.
  60. ;        So I'm unsure if I need to wait for delimessages in the config...
  61. ; 980218:0032    (009) Added a few gadget-routines to the open/close window routines, and also
  62. ;        made them access the data relative to a5. It worked from the start! So now I have
  63. ;        a 'Select executabe...' gadget in the config-window! (does nothing yet though).
  64. ; 980218:0138    (010) dr_Init will now open reqtools.library and allocate a filerequest
  65. ;        structure. When the 'select executable...' button is pressed, a reqtools
  66. ;        filerequester pops up.
  67. ;        ** There seem to be a problem though. Sometimes when I press the config-window's
  68. ;        close-gadget, delitracker will load the next module!! Hmm... this is probably
  69. ;        because delitracker is somehow halted while I'm in the config-part, since
  70. ;        the message that caused DeliRave to go into the config-mode isn't replied to
  71. ;        until I exit it. The mpega config spawns a new process for itself, maybe this
  72. ;        is why.
  73. ; 980218:1645    (011) Made a config-structure with room for future improvements (to include
  74. ;        all settings the Ravescope can have). The selected filename is stored in
  75. ;        the settings now.
  76. ; 980218:1924    (012) The Show button now calls rs_Appear, which will Execute("Run ravescope")
  77. ;        or whatever the path is. Wrote a routine in the RaveScope source that will
  78. ;        establish the connection, but I haven't written a corresponding routine for this
  79. ;        genie yet. Moved the config structure and global data structure definitions
  80. ;        into an include file, and made a .h version of it for inclusion by the Ravescope.
  81. ; 980219:1752    (012) Made some more variable references relative to a5. Apparently Delitracker's
  82. ;        internal routines for locking/unlocking the public screen require a5 to be
  83. ;        loaded with DeliBase.
  84. ; 980219:1823    (013) Made the rest of the references a5-relative and moved dr_Data into a
  85. ;        BSS section.
  86. ; 980223:1331    (014) I have now managed to establish a connection between the ravescope and
  87. ;        DeliRave. Seems to work fine. 
  88. ; 980224:1957    (015) Added many flags and variables to the ScopeHeader and ScopeChannel
  89. ;        structures. There's now 3 ScopeHeader structures in the DeliRave global data.
  90. ;        When the interrupt is called, I will from there called dr_Get4Update. It will
  91. ;        look on these three headers to determine the one that is most suitable to
  92. ;        update, at the same time increasing their "freshness" values. If a header
  93. ;        has its scph_DISPLAYED flag set, it means that this header and its channel
  94. ;        structures are being used at the moment to display the scope. This header is
  95. ;        thus immediately disregarded. If there are several likely candidates, the one
  96. ;        that is least fresh (i.e was updated the longest time ago) will be returned to
  97. ;        the interrupt for update, after the scph_UPDATED flag has been set.
  98. ;        ** The RaveScope will call dr_Get4Disp, a similar routine that will look at the
  99. ;        three ScopeHeader structures to determine which one is the most suitable for
  100. ;        display. If a header has its scph_UPDATED flag set, it means it's being updated
  101. ;        at the moment, and thus it's disregarded. If the flag scph_INVALID is set, it
  102. ;        means that this header has already been used to produce a display, so it is
  103. ;        likewise disregarded. If there's several ScopeHeader structures that are available
  104. ;        for display, the one that is the freshest (i.e was updated most recently) is
  105. ;        chosen by setting its scph_DISPLAYED flag. Before it is returned to the RaveScope
  106. ;        though, the scph_UPDATED flag is checked. If it has been grabbed and set by the
  107. ;        interrupt in the meantime, it's not possible to display it, so the whole
  108. ;        dr_Get4Disp is called again.
  109. ; 980224:2017    (015) dr_StartRave and dr_StopRave will start/stop the ravescope
  110. ;        dr_InitPlay (which I guess is called when Delitracker has been stopped (and
  111. ;        deallocated its audiochannels) will now examine the NoteInfo structure to
  112. ;        determine the amount of channels the player can supply. If there are no allocated
  113. ;        channel structures, 16 will be allocated 3 times (one set for each ScopeHeader).
  114. ;        If there are some, but not enough, the old ones will first be deallocated.
  115. ;        Then the scph_MaxChans will be doubled. If this isn't enough it will be doubled
  116. ;        again until it is equal or larger than the amount of channels DeliTracker will
  117. ;        supply to it. If the allocation is successful, all headers and their channel
  118. ;        structs are inited. The scope is then started.
  119. ;        ** dr_EndPlay (which I guess is called when the eject button is pressed in
  120. ;        Delitracker) will stop the scope and clear some important fields in the notechan
  121. ;        structures, to make sure they are not used later for display by the RaveScope.
  122. ; 980225:0030    (016) Made a debug macro (DBUG) which will call KPrintF and print the supplied
  123. ;        string, without changing any registers. Filled the source with this macro...
  124. ; 980225:0117    (016) Fixed some problems related to the rs.scope_stop and rs.scope_stopped
  125. ;        being BOOL (16 bits) and not byte as I used on the asm-side.
  126. ;        ** Eject (after play) results in:
  127. ;        dr_StopSnd, dr_EndSnd, dr_EndPlay.
  128. ;        ** When, after eject, I press play, this is the order:
  129. ;        dr_InitPlay, dr_InitSnd, dr_StartSnd.
  130. ;        ** When I turn off the sound with the play/pause button, dr_StopSnd is called.
  131. ;        When I turn it on again (play after pause), dr_StartSnd is called.
  132. ;        ** When I turn it off with the stop-button, these are called:
  133. ;        dr_StopSnd, dr_EndSnd, dr_InitSnd.
  134. ;        Play after stop results only in dr_StartSnd.
  135. ;        ** Stop after pause = dr_EndSnd, dr_InitSnd,
  136. ;        eject after stop = dr_EndSnd, dr_EndPlay.
  137. ;        These are not always called though! May depend on the module format.
  138. ;        It seems I need to call some of those routines manually when delirave is
  139. ;        started when delitracker is already running.
  140. ;        Also appear to be some problems with NCHD_Ignore. All (or so it seems)
  141. ;        channels are ignored for s3m:s, xm:s and indigo trackers..
  142. ; 980225:1536    (016) I'm now opening the timer.device and allocating a message port for it,
  143. ;        to make use of Peter's routines to calculate the sample locations.
  144. ;        ** Changed 4 quitflag bytes into bits to fit into one single byte, dr_oStopFlags.
  145. ;        The RaveScope now only need to check this byte to determine if DeliRave is
  146. ;        active or not.
  147. ;        ** The DRSFB_PLYSTOPPED is supposed to be set ONLY when delitracker (and
  148. ;        not DeliRave) is stopped. This flag is updated in StartSnd and StopSnd only.
  149. ;        When DeliRave needs some privacy, it will call dr_StopRave, which will no longer
  150. ;        set the delitracker stop-flag, but DRSFB_DELIBUSY and signal to the RaveScope
  151. ;        that it must stop, by setting the scope_stop and waiting for scope_stopped to
  152. ;        become true.
  153. ; 980302:0132    (017) Corrected many bugs, and finally got a display! But it seems that every
  154. ;        second time DoWrapped is called, a blank frame will be produced (because it
  155. ;        flickers a lot) and what's worse, the sample pointers do not seem to be updated
  156. ;        at all (only the initial position appear to be correct).
  157. ; 980302:0202    (017) Yes! I had forgotten to add the elapsed sample bytes to the pointers!
  158. ;        I only subtracted it from the remaing bytes. Looks much better now, but still
  159. ;        flashes.
  160. ; 980302:1835    (018) Got it to work today! To start with I had forgotten that when updating
  161. ;        the channel structures, I needed to know their previous values, since using
  162. ;        several sets of structures, there would be a new set each time.
  163. ;        Also I had some problems with the scph_oFlags not being set/cleared properly,
  164. ;        so the routine to get headers ready for update/display didn't produce the
  165. ;        wanted result. I'm right now fighting with enforcer hits occuring sometimes
  166. ;        when I change module (from the wrapped's inner loop). I've now tried to init
  167. ;        the critical fields in the scopechannel structures each time a new module is
  168. ;        loaded.
  169. ; 980302:2102    (019) Enforced a very strict sieve policy in the NoteSignal routine, to get
  170. ;        rid of 'locked' sample-loops. Seems to work very well (too well sometimes
  171. ;        perhaps). I've been trying many mods, and they all seem to work good. But
  172. ;        8 channel octamed modules (orpheus ones) will display a lot of crap, which
  173. ;        could be because of a certain sample.. Don't know, haven't found other 8
  174. ;        channel octameds...
  175. ;        ** Began with a 10 channel fasttracker mod (first in trance), but DeliRave
  176. ;        allocated 32 channels for it! (didn't use them, just alloc room for it).
  177. ; 980302:2133    (019) trance/blueprint is s3m and uses unsigned samples.
  178. ; 980303:1835    (020) Unsigned samples are no longer a problem.
  179. ;        ** But my new sample-nuke policy made the mp3's flicker again. I commented
  180. ;        out the 'check if new samplepos = old samplepos and nuke if so' line, and this
  181. ;        got rid of it. Some pt-mods with loops seem to flicker still though.
  182. ; 980304:0113    (021) Rewrote and optimized the routine to keep track of the sample positions.
  183. ;        The result is much better!
  184. ; 980304:0113    (022) Added two menu items, Popup = steal and Quit = kill. I have problems with
  185. ;        killing the RaveScope without causing deadlocks. Will have to try again when
  186. ;        I'm not so tired & confused.
  187. ; 980304:1528    (022) Phew, finally it works.
  188. ; 980304:1637    (023) Moved the dr_Get4Update into the monoscope source. I'm calling it now
  189. ;        through a pointer supplied by the RaveScope.
  190. ; 980304:1836    (023) Did the same with the routine to check if the new amount of channels for
  191. ;        a player is enough, and double the #of channel structures if it isn't. It's
  192. ;        now called ms_GetRoom, and its address can be found in dr_oGetRoom_f.
  193. ; 980304:2038    (023) Added some routines to pass a correct DeliRave config to the RaveScope.
  194. ;        Does not work properly yet (I think it's corrupted).
  195. ; 980306:1355    (023) The config can be loaded and saved now and will be passed correctly.
  196. ; 980308:0156    (024) Added a check for 020 in the beginning and an Easyrequester if no 020
  197. ;        was found. Also added a requester for when the RaveScope could not be found.
  198. ; 980308:1535    (024) Now DeliRave will not kill the RaveScope if it is used by another player.
  199. ; 980310:2320    (025) Had horrible problems with the whole project, as the config must have
  200. ;        gotten invalid, producing *hard* crashes. The config can no longer be saved
  201. ;        when the RaveScope is not present.
  202. ;        ** I rewrote the FindRave routine, so it will no longer try to Execute() the
  203. ;        RaveScope several times. Also Peter Kunath told me that he couldn't get his
  204. ;        old version to work. And it locked when starting DeliTracker from icon. I'm
  205. ;        opening NIL: filehandles now and I'm going to pass them to Execute()....
  206. ; 980310:2337    (025) At least this works for me when starting DT from icon.
  207. ; 980314:2257    (026) Changed the Execute() call (to start the Ravescope) into a SystemTagList()
  208. ;        call. Had much problems with this, and I had to give up trying to pass the tag
  209. ;        NP_Arguments, as it did not work with a input handle as NIL: or anything else
  210. ;        I tried. Gave enforcer hits and made nothing.
  211. ; 980315:0012    (027) Changed the flag (Popup etc) handling. Made it more modular and attempted
  212. ;        to make it accurately visualize the current settings (after a reset config).
  213. ;        But I had to close the config-window and reopen it to make that happen.
  214. ;        Reinserted the routines to keep track of the window positions. Don't know why
  215. ;        I removed that since the positions are stored in the config...
  216. ; 980315:2054    (027) Released version 1.0 (RaveScope v1.1) on Aminet with this source (027).
  217. ; 980324:0417    (028) Peter reported some enforcer-hits. The originated from a move.l from
  218. ;        the old scopechannel structure. The old scopechannel structure could be zero
  219. ;        sometimes. If it is, I'll branch to a routine which does not access the old
  220. ;        scopechannel structure, but I found that in a certain case it would branch
  221. ;        out of this routine, to the one that do access it! Fixed this...
  222. ; 980411:1641    (029) I'm cutting out most of this source, as I am now rewriting it to work
  223. ;        with the new host concept. So instead of having delitracker specific routines,
  224. ;        I call a similar routine from hostfuncs.o. Removed everything that dealt with
  225. ;        the config window.
  226. ; 980413:0142    (029) It works with the RaveScope again, finally.
  227. ; 980906:1227    (058) Sometimes after a module had been stopped, delirave would send a PLYACTIVE
  228. ;        message from dr_InitSnd. Removed this which fixed the problem.
  229. ; 980922:0007    (065) *** Released version 1.2 on Aminet with this source (065).
  230.  
  231.         MACHINE    68020
  232.  
  233. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  234. *
  235.         SECTION GenieCode,Code
  236.  
  237.  
  238.         INCDIR    include:
  239.         INCLUDE    delitracker/DeliPlayer.i
  240.  
  241.         PLAYERHEADER GenieTagArray
  242.  
  243. dr_Version:    dc.b '$VER: RaveScope-Genie 1.2 (22.9.98)',0
  244.         even
  245.  
  246. GenieTagArray    dc.l    DTP_RequestDTVersion,17            ; minimum DT version needed
  247.         dc.l    DTP_PlayerVersion,01<<16+02        ; actual player version & revision
  248.         dc.l    DTP_PlayerName,GName            * name of this player/genie
  249.         dc.l    DTP_Creator,CName            * author of the player/genie
  250.         dc.l    DTP_Description,DName            * description of the player/genie
  251.         dc.l    DTP_DeliBase,dr_oDeliBase+dr_Data    * store DeliGlobals ptr here
  252.         dc.l    DTP_Process,dr_Begin            ; pointer to process entry code
  253.         dc.l    DTP_Priority,-5                ; priority of the process
  254.         dc.l    DTP_StackSize,4096            ; stack size of the process
  255.         dc.l    DTP_MsgPort,dr_oDeliPort+dr_Data    * DT sends msgs to this port
  256.         dc.l    DTP_NoteInfo,dr_oNoteInfo+dr_Data    * Store ptr to NoteStruct here
  257.         dc.l    DTP_NoteSignal,dr_NoteSignal        ; ptr to NoteSignal interrupt code
  258.         dc.l    DTP_Appear,dr_Appear            * routine to open the window
  259.         dc.l    DTP_Disappear,dr_Disappear        * routine to close the window
  260.         dc.l    DTP_InitPlayer,dr_InitPlay        ; Get info about current player
  261.         dc.l    DTP_EndPlayer,dr_EndPlay        * genie cleanup code: ply stopped
  262.         dc.l    DTP_InitSound,dr_InitSnd        ; Upd chanstr here *clr chan str
  263.         dc.l    DTP_EndSound,dr_EndSnd            * clear channel structs
  264.         dc.l    DTP_StartInt,dr_StartSnd        * install VBL interrupt
  265.         dc.l    DTP_StopInt,dr_StopSnd            * remove VBL interrupt
  266.         dc.l    TAG_DONE
  267.  
  268. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  269. *
  270. *        INCLUDES &c
  271.  
  272.         INCLUDE    exec/exec_lib.i
  273.         INCLUDE    exec/exec.i
  274.         INCLUDE    exec/tasks.i
  275.         INCLUDE    devices/timer_lib.i
  276.         INCLUDE    devices/timer.i
  277.         INCLUDE    dos/dos_lib.i
  278.         INCLUDE    dos/dos.i
  279.         INCLUDE    dos/dostags.i
  280.         INCLUDE graphics/graphics_lib.i
  281.         INCLUDE    graphics/gfx.i
  282.         INCLUDE    hardware/intbits.i
  283.         INCLUDE    intuition/intuition_lib.i
  284.         INCLUDE    intuition/intuition.i
  285.         INCLUDE    libraries/gadtools_lib.i
  286.         INCLUDE    libraries/gadtools.i
  287.         INCLUDE    libraries/reqtools.i
  288.         INCLUDE    libraries/reqtools_lib.i
  289.         INCDIR    ""
  290.         INCLUDE    include/monoscope.i
  291.         INCLUDE    include/ravescope.i
  292.         INCLUDE    include/delirave.i
  293.  
  294.         XREF    _rh_InitHost                * Init this host
  295.         XREF    _rh_FreeHost                * Free everything done in InitHost
  296.         XREF    _rh_ProcMsgs                * Process msgs from Rave
  297.         XREF    _rh_WaitPutMsg                * PutMsg to Rave and wait 4 reply
  298.         XREF    _rh_SignalRave                * PutMsg Rave & wait IF WE HAVE IT
  299.         XREF    _rh_PlyActive                * Tell Rave we're playing
  300.         XREF    _rh_ClrChans                * Clear one header's channels
  301.         XREF    _rh_NukeChans                * Clear all header's channels
  302.         XREF    _rh_GrabRave                * Try to grab/launch the RaveScope
  303.         XREF    _rh_AddSig                * Add sig (d0) to the signalmask
  304.  
  305. MYDEBUG:    equ    0
  306. DEBTIME:    equ    0
  307. dr_RELEASE:    equ    1
  308. dr_VERSION:    equ    102
  309.  
  310. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  311. *
  312. *        MACROS
  313.  
  314. PUSH:        MACRO
  315.         IFC    "\1","ALL"
  316.         movem.l    d0-a6,-(sp)
  317.         ELSE    
  318.         movem.l    \1,-(sp)
  319.         ENDC
  320.         ENDM
  321.  
  322. POP:        MACRO
  323.         IFC    "\1","ALL"
  324.         movem.l    (sp)+,d0-a6
  325.         ELSE    
  326.         movem.l    (sp)+,\1
  327.         ENDC
  328.         ENDM
  329.  
  330. CALLLVO:    MACRO
  331.             jsr    _LVO\1(a6)
  332.         ENDM
  333. JUMPLVO:    MACRO
  334.             jmp    _LVO\1(a6)
  335.         ENDM
  336.  
  337. CALLEXE:    MACRO
  338.         move.l    dr_oSysBase(a5),a6
  339.             jsr    _LVO\1(a6)
  340.         ENDM
  341. JUMPEXE:    MACRO
  342.         move.l    dr_oSysBase(a5),a6
  343.             jmp    _LVO\1(a6)
  344.         ENDM
  345.  
  346. CALLGFX:    MACRO
  347.         move.l    dr_oGfxBase(a5),a6
  348.             jsr    _LVO\1(a6)
  349.         ENDM
  350. JUMPGFX:    MACRO
  351.         move.l    dr_oGfxBase(a5),a6
  352.             jmp    _LVO\1(a6)
  353.         ENDM
  354.  
  355. CALLDOS:    MACRO
  356.         move.l    dr_oDOSBase(a5),a6
  357.             jsr    _LVO\1(a6)
  358.         ENDM
  359. JUMPDOS:    MACRO
  360.         move.l    dr_oDOSBase(a5),a6
  361.             jmp    _LVO\1(a6)
  362.         ENDM
  363.  
  364. CALLGAD:    MACRO
  365.         move.l    dr_oGTBase(a5),a6
  366.             jsr    _LVO\1(a6)
  367.         ENDM
  368. JUMPGAD:    MACRO
  369.         move.l    dr_oGTBase(a5),a6
  370.             jmp    _LVO\1(a6)
  371.         ENDM
  372.  
  373. CALLITN:    MACRO
  374.         move.l    dr_oIntuiBase(a5),a6
  375.             jsr    _LVO\1(a6)
  376.         ENDM
  377. JUMPITN:    MACRO
  378.         move.l    dr_oIntuiBase(a5),a6
  379.             jmp    _LVO\1(a6)
  380.         ENDM
  381.  
  382.         IFNE    MYDEBUG                    ;Debug macro. Link with include:
  383.         XRef    KPrintF                    ;link/debug.lib & link/amiga.lib
  384.         ENDC
  385.  
  386. DBUG:        MACRO
  387.         IFNE    MYDEBUG
  388.         IFNE    NARG-1
  389.         subq.w    #1,.Ctr\@
  390.         bne    .Skip\@
  391.         move.w    #\2,.Ctr\@
  392.         bra    .Debug\@
  393. .Ctr\@:        dc.w    1
  394.         ELSE
  395.         bra    .Debug\@
  396.         ENDC
  397. .Str\@:        dc.b    "DELI: ",\1,0
  398.         EVEN
  399. .Debug\@:    DBUGIT    .Str\@
  400. .Skip\@:    *+-
  401.         ENDC
  402.         ENDM
  403.  
  404. DBUGIT:        MACRO
  405.         IFNE    MYDEBUG
  406.         movem.l    d0-a6,-(sp)
  407.         move.l    4.w,a6
  408.         jsr    _LVOForbid(a6)
  409.         lea    \1,a0
  410.         suba.l    a1,a1
  411.         jsr    KPrintF
  412.         move.l    4.w,a6
  413.         jsr    _LVOPermit(a6)
  414.         IFNE    DEBTIME
  415.         move.l    dr_oDOSBase(a5),d0
  416.         beq    .Skip\@
  417.         move.l    d0,a6
  418.         move.l    #DEBTIME,d1
  419.         jsr    _LVODelay(a6)
  420.         ENDC
  421. .Skip\@:    movem.l    (sp)+,d0-a6
  422.         ENDC
  423.         ENDM
  424.  
  425. LEASTR:        MACRO
  426.         bsr    .skip\@
  427.         dc.b    \1,0
  428.         EVEN
  429. .skip\@:    move.l    (sp)+,\2
  430.         ENDM
  431.  
  432. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  433. *
  434. *        Genie/Creatorname/Description und lokale Daten
  435.  
  436. GName        dc.b    'RaveScope',0
  437. CName        dc.b    'By Parsec 1998 (Erik Spåre)',10
  438.         dc.b    'Based on a source by Peter Kunath',0
  439. DName        dc.b    'This genie displays waveforms,',10
  440.         dc.b    '(any number of channels are supported)',10
  441.         dc.b    'It requires RaveScope 1.2 or above.',0
  442.         even
  443.  
  444. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  445. *
  446. *        Player Process
  447.  
  448. dr_Begin:    lea    dr_Data,a5                * Get DeliRave data
  449.         DBUG    "DeliRave started.\n"
  450.         bsr    dr_Init
  451.         beq    .Quit
  452.  
  453. .Main:        DBUG    "Going to sleep in the main-loop...\n\n"
  454.         move.l    rh_oSigMask(a5),d0
  455.         CALLEXE Wait                    ; Schlaf gut
  456.         DBUG    "Yawn...\n"
  457.  
  458.         move.l    d0,d2                    ; copy SignalMask
  459.         btst.l    #SIGBREAKB_CTRL_C,d2            ; CTRL-C signal ?
  460.         beq    .DeliCollect                ; nope !
  461.         bsr    dr_Exit                    ; suicide :)
  462.  
  463. .DeliCollect    move.l    dr_oDeliPort(a5),a0            ; collect DeliTracker msg's
  464.         CALLEXE GetMsg
  465.         tst.l    d0                    ; Msg da ?
  466.         beq    .Collected                ; Nein !
  467.         move.l    d0,-(sp)                ; store ^Msg
  468.         move.l    d0,a0
  469.         move.l    DTMN_Function(a0),a0            ; get CMD
  470.         jsr    (a0)                    ; Befehl ausführen
  471.         move.l    (sp)+,a1                ; restore ^Msg
  472.         move.l    d0,DTMN_Result(a1)            ; set Result
  473.         CALLEXE ReplyMsg                ; return to sender
  474.         bra    .DeliCollect
  475.  
  476. .Collected:    jsr    _rh_ProcMsgs                * Proc host-messages
  477.         tst.b    dr_oQuit(a5)                * Quit?
  478.         beq    .Main
  479.  
  480. .Quit:        bsr    dr_CleanUp
  481.         DBUG    "Exiting DeliRave...\n"
  482.         rts
  483.  
  484.  
  485. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  486. *
  487. *        Init everything
  488.  
  489. dr_Init:    DBUG    "** Entered dr_Init.\n"
  490.  
  491.         move.l    4.w,a6                    * Get SysBase
  492.         move.l    dr_oDeliBase(a5),a4            * Get DeliBase
  493.         move.l    a6,dr_oSysBase(a5)
  494.         move.l    dtg_DOSBase(a4),dr_oDOSBase(a5)
  495.         move.l    dtg_GfxBase(a4),dr_oGfxBase(a5)
  496.         move.l    dtg_GadToolsBase(a4),dr_oGTBase(a5)
  497.         move.l    dtg_IntuitionBase(a4),dr_oIntuiBase(a5)
  498.         clr.b    dr_oQuit(a5)                * Clear the quit-flag
  499.  
  500.         move.l    #dr_ConfigEnv,d1            * Read the envvariable DELICONFIG,
  501.         move.l    #dr_ConfigPath,d2            * constituting the path to the
  502.         moveq    #120,d3                    * configuration files. Store
  503.         moveq    #0,d4                    * the result in ConfigPath
  504.         CALLDOS GetVar
  505.         tst.l    d0
  506.         beq    .Error
  507.  
  508.         move.l    #dr_ConfigPath,d1            * Get the full path to the DeliRave
  509.         move.l    #dr_ConfigFile,d2            * config in ConfigPath
  510.         moveq    #120,d3
  511.         CALLDOS AddPart
  512.         tst.l    d0
  513.         beq    .Error
  514.  
  515.         LEASTR    "Delitracker",a0            * Name of your host
  516.         lea    dr_ConfigPath,a1            * Path to your config-file
  517.         lea    dr_Data,a5                * Put the RaveHost structure here
  518.         CLEARA    a2                    * No tags!
  519.         jsr    _rh_InitHost                * Init it...
  520.         beq    .Error                    * Serious error, quit and report failure...
  521.  
  522.         move.b    #SIGBREAKB_CTRL_C,d0            * Add CTRL-C signal to the mask
  523.         jsr    _rh_AddSig
  524.         move.b    ([dr_oDeliPort,a5],MP_SIGBIT),d0    * Add DT's msgportbit to the mask
  525.         jsr    _rh_AddSig
  526.  
  527.         tst.l    dr_oTimePort(a5)
  528.         bne    .NoTimsg
  529.         DBUG    "Creating msg-port for use with timer.device.\n"
  530.         CALLEXE    CreateMsgPort
  531.         move.l    d0,dr_oTimePort(a5)
  532.         beq    .Error
  533.  
  534. .NoTimsg:    tst.b    dr_oTimerOpen(a5)
  535.         bne    .NoTimer
  536.         DBUG    "Opening timer.device.\n"
  537.         lea    dr_oTimeReq(a5),a1            * set ReplyPort for TimeRequest
  538.         move.l    d0,MN_REPLYPORT(a1)
  539.         lea    dr_TimerName,a0                * Get timer.device name
  540.         moveq    #UNIT_VBLANK,d0
  541.         CLEAR    d1
  542.         CALLEXE    OpenDevice                * Open timer.device
  543.         tst.l    d0                    * Successful? (NULL)
  544.         seq    dr_oTimerOpen(a5)            * Set timer opened flag if so
  545.         bne    .Error
  546.  
  547. .NoTimer:    DBUG    "Everything inited ok!\n"
  548.         moveq    #1,d0
  549.         rts
  550.  
  551. .Error:        DBUG    "Something went wrong!\n"
  552.         moveq    #0,d0
  553.         rts
  554.  
  555.  
  556. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  557. *
  558. *        Cleanup DeliRave
  559.  
  560. dr_CleanUp:    DBUG    "** Entered dr_CleanUp.\n"
  561.         bsr    dr_StopSnd
  562.         bsr    dr_EndPlay
  563.  
  564.         tst.b    dr_oTimerOpen(a5)            * Was timer.device opened?
  565.         beq    .NoTime
  566.         DBUG    "Closing timer.device.\n"        * Yes, so close it.
  567.         lea    dr_oTimeReq(a5),a1
  568.         CALLEXE    CloseDevice
  569.         clr.b    dr_oTimerOpen(a5)
  570.  
  571. .NoTime:    move.l    dr_oTimePort(a5),d0            * Was msgport for timer created?
  572.         beq    .NoPort
  573.         DBUG    "Deleting timer.device's msgport...\n"
  574.         move.l    d0,a0                    * Yes, delete it.
  575.         CALLEXE    DeleteMsgPort
  576.         clr.l    dr_oTimePort(a5)
  577.  
  578. .NoPort:    jsr    _rh_FreeHost                * Free the host
  579.  
  580.         DBUG    "Everything cleaned up!\n"
  581.         rts                        ; Playerprozess beenden
  582.  
  583.  
  584. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  585. *
  586. *        Init the ScopeHeader and its ScopeChannel structures, alloc them if necessary
  587.  
  588. dr_InitPlay:    DBUG    "** dr_InitPlay:  PLYACTIVE -> Rave\n"    * Tell the RaveScope (if present) that
  589.         jsr    _rh_PlyActive                * we're about to play (and grab it!)
  590.         move.w    #RMSG_HOSTBUSY,d0            * Make sure RaveScope is stopped
  591.         jsr    _rh_SignalRave
  592.         beq    .Exit
  593.  
  594.         DBUG    "## Checking NoteInfo ##\n"
  595.         move.l    dr_oNoteInfo(a5),d0            * Get notestructure
  596.         beq    .Error
  597.         move.l    d0,a3                    * a3 = NoteStructure
  598.  
  599.         DBUG    "## Checking channels ##\n"
  600.         move.l    nst_Channels(a3),d0            * pointer to first channel in list
  601.         beq    .Error
  602.         DBUG    "Calculating #of channels...\n"
  603.         moveq    #0,d6                    * d6 = #of channels
  604. .GetNums:    addq.w    #1,d6
  605.         move.l    d0,a0
  606.         move.l    nch_NextChannel(a0),d0
  607.         bne    .GetNums
  608.  
  609.         move.w    d6,d0                    * New #of channels
  610.         moveq    #3-1,d1                    * Three sets of chanstructs
  611.         lea    rh_oChanHdrs(a5),a0            * Pointer to channel headers
  612.         jsr    ([rh_oMakeRoom_f,a5])            * Ensure there's room 4 all chans
  613.         beq    .Error                    * It isn't, error!
  614.  
  615.         move.l    a0,a4                    * a4 = ptr to channel headers
  616.         moveq    #3-1,d7                    * Init 3 channel headers w/structs
  617. .InitLoop:    move.l    nst_Channels(a3),d0            * Pointer to first NoteChannel
  618.         move.l    scph_oChannels(a4),a1            * Ptr to first ScopeChannel
  619.  
  620. .CountLoop    move.l    d0,a0                    * Get NoteChannel struct
  621.         move.w    nch_Stereo(a0),d0            * Get stereo field
  622.         cmpi.w    #NCHD_Ignore,d0                * Ignore this channel?
  623.         beq    .Skip                    * Yes!
  624.         move.l    a0,scpc_oExtChan(a1)            * Store ptr to the corresponding
  625.         move.l    #8287,scpc_oFreq(a1)            * Set frequency
  626.         bra    .Next                    * Deli NoteChannel in ScopeChannel
  627. .Skip:        subq.w    #1,scph_oNumChans(a4)            * One channel less
  628. .Next:        lea    scpc_SIZEOF(a1),a1            * Go to next ScopeChannel struct
  629.         move.l    nch_NextChannel(a0),d0            * Go to next NoteChannel struct
  630.         bne    .CountLoop
  631.  
  632. .MaxChannels:    move.l    nst_Flags(a3),d0            * get NotePlayer flags
  633.         btst.l    #NSTB_7Bit,d0
  634.         beq    .Try8
  635.         bset.b    #SCPHB_7BITS,scph_oFlags(a4)        * Display 7 bit sound
  636.         bra    .BitsOk
  637. .Try8:        btst.l    #NSTB_8Bit,d0
  638.         beq    .Try16
  639.         bset.b    #SCPHB_8BITS,scph_oFlags(a4)        * Display 8 bit sound
  640.         bra    .BitsOk
  641. .Try16:        btst.l    #NSTB_16Bit,d0                * Last chance. No 7/8/16 bit
  642.         beq    .Error                    * Specification means error.
  643.         bset.b    #SCPHB_16BITS,scph_oFlags(a4)        * Display 16 bit sound
  644.  
  645. .BitsOk:    btst.l    #NSTB_Signed,d0                * Signed Samples?
  646.         beq    .Unsigned
  647.         bset.b    #SCPHB_SIGNED,scph_oFlags(a4)        * Display signed samples
  648.         bra    .SignOk
  649. .Unsigned    btst.l    #NSTB_Unsigned,d0            * Unsigned Samples?
  650.         beq    .Error                    * Neither signed/unsinged => error
  651.         bclr.b    #SCPHB_SIGNED,scph_oFlags(a4)        * Display signed samples
  652.  
  653. .SignOk:    move.w    nst_MaxVolume(a3),scph_oMaxVolume(a4)    * Set maximum volume
  654.         bset.b    #SCPHB_INVALID,scph_oFlags(a4)        * Not yet valid for display
  655.         jsr    _rh_ClrChans                * Clear scopechannel structs
  656.         lea    scph_SIZEOF(a4),a4
  657.         dbra    d7,.InitLoop                * Init next set of hdr & chans
  658.  
  659.         DBUG    "All notestructures inited as follows:\n"
  660.         ifne    MYDEBUG
  661.         move.b    scph_oFlags-scph_SIZEOF(a4),d0
  662.         btst    #SCPHB_7BITS,d0
  663.         beq    1$
  664.         DBUG    "7 Bit\n"
  665. 1$:        btst    #SCPHB_8BITS,d0
  666.         beq    2$
  667.         DBUG    "8 Bit\n"
  668. 2$:        btst    #SCPHB_16BITS,d0
  669.         beq    3$
  670.         DBUG    "16 Bit\n"
  671. 3$:        btst.b    #SCPHB_SIGNED,d0
  672.         beq    4$
  673.         DBUG    "Signed samples,\n"
  674.         bra    5$
  675. 4$:        DBUG    "Unsigned samples,\n"
  676. 5$:        lea    .Numstr+6,a0
  677.         move.w    scph_oNumChans-scph_SIZEOF(a4),d0
  678.         bsr    .PutDigit
  679.         DBUGIT    .Numstr    
  680.         lea    .Nummax+6,a0
  681.         move.w    scph_oMaxChans-scph_SIZEOF(a4),d0
  682.         bsr    .PutDigit
  683.         DBUGIT    .Nummax
  684.         bra    8$
  685. .PutDigit:    andi.l    #$FFFF,d0
  686.         cmp.w    #9,d0
  687.         bgt    6$
  688.         add.b    #'0',d0
  689.         move.b    d0,(a0)+
  690.         move.b    #' ',(a0)
  691.         bra    7$
  692. 6$:        divu    #10,d0
  693.         add.b    #'0',d0
  694.         move.b    d0,(a0)+
  695.         swap    d0
  696.         add.b    #'0',d0
  697.         move.b    d0,(a0)+
  698. 7$:        rts
  699. .Numstr:    dc.b    "DELI: xx channels\n",0
  700. .Nummax:    dc.b    "DELI: xx slots currently allocated.\n",0
  701.         even
  702. 8$:
  703.         ENDC
  704.  
  705.         DBUG    "Telling Rave we're not busy anymore\n"
  706.         move.w    #RMSG_HOSTREADY,d0
  707.         jsr    _rh_SignalRave                * Restart the ravescope
  708. .Exit:        CLEAR    d0                    * Signal success
  709.         rts
  710.  
  711. .Error:        DBUG    "Something went wrong in dr_InitPlay!\n"
  712.         moveq    #-1,d0                    * Signal failure
  713.         rts
  714.  
  715. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  716. *
  717. *        Daten für Scope Display updaten
  718.  
  719. dr_NoteSignal:    ;DBUG    "Got notesignal\n",30
  720.         movem.l    d2-d7/a2-a6,-(sp)
  721.         lea    dr_Data,a5
  722.         move.l    rh_oRaveBase(a5),d0            * Are we used by the RaveScope?
  723.         beq    .Out                    * No, exit.
  724.         move.l    d0,a0
  725.         tst.b    rs_oStopFlags(a0)            * Is the RaveScope active?
  726.         bne    .Out                    * No, don't update anything
  727.  
  728. ;        DBUG    "Getting hdr 2 upd\n",30
  729.         lea    rh_oChanHdrs(a5),a0            * Find a header to update
  730.         moveq    #3-1,d0
  731.         move.l    rh_oGet4Upd_f(a5),a4            * Get adr to ms_Get4Update()
  732.         jsr    (a4)                    * Get d0=header struct to update
  733.         beq    .Out                    * None available => exit
  734.         move.l    d0,a4                    * a4=header to update
  735.  
  736.         move.l    dr_oNoteInfo(a5),d0            * Check NoteStructure
  737.         beq    .Exit                    * Not available, so exit.
  738.  
  739. ;        DBUG    "Updating header\n",30
  740.         move.l    dr_oTimeReq+IO_DEVICE(a5),a6        * Get TimerBase
  741.         lea    dr_oEClockVal1(a5),a0            * read EClock Value
  742.         jsr    _LVOReadEClock(a6)
  743.         move.l    d0,d5                    * EClockFreq (ticks/sec)
  744.  
  745.         lea    dr_oEClockVal1(a5),a0            * Calc Interrupt Time
  746.         lea    dr_oEClockVal2(a5),a1
  747.         move.l    EV_LO(a0),d0
  748.         sub.l    EV_LO(a1),d0
  749.         beq    .CopyEClock
  750.         divu    d0,d5
  751.         moveq    #0,d6
  752.         move.w    d5,d6                    * d6 = clock divisor
  753. .CopyEClock:    tst.w    d6                    * Make sure d6 isn't zero
  754.         bne    .NotZero
  755.         moveq    #1,d6
  756. .NotZero:    move.l    (a0)+,(a1)+                * copy EClock Value
  757.         move.l    (a0)+,(a1)+
  758.  
  759. ;        DBUG    "!Checking channels...\n",30
  760.         move.l    scph_oChannels(a4),d0
  761.         beq    .Exit
  762. ;        DBUG    "Channels !OK!\n",30
  763.         move.l    d0,a3                    * a3 = ScopeChannel struct
  764.         move.w    scph_oNumChans(a4),d7            * d7 = #of channels = dbra
  765.         move.l    rh_oOldScph(a5),a6            * Get old scopeheader
  766.         move.l    a4,rh_oOldScph(a5)            * This ScopeHeader old next time
  767.         tst.l    a6
  768.         beq    .OnlyNew
  769.         move.l    scph_oChannels(a6),a6            * Get old channels
  770.         tst.l    a6
  771.         bne    .BegLoop
  772.         bra    .OnlyNew
  773.  
  774. .OnlyLoop:    move.l    scpc_oExtChan(a3),d0            * Get NoteChannel struct
  775.         beq    .Exit                    * Exit if not present (must be)
  776.         move.l    d0,a2                    * a2 = NoteChannel struct
  777.         CLEAR    d0                    * d0 = No sample length
  778.         CLEAR    d1                    * d1 = No sample pos
  779.         CLEAR    d2                    * d2 = No loop length
  780.         CLEAR    d3                    * d3 = No loop pos
  781.         CLEAR    d4                    * d4 = No frequency
  782.         CLEAR    d5                    * d5 = No volume
  783.         cmpi.w    #NCHD_Ignore,nch_Stereo(a2)        * skip this channel ?
  784.         beq    .NextNew                * yes !
  785.         btst.b    #NCHB_Volume,nch_Changed(a2)        * New volume?
  786.         beq    .SkipV                    * No
  787.         move.w    nch_Volume(a2),d5
  788.         cmp.w    #64,d5                    * Vol may not exceed
  789.         ble    .SkipV                    * 64 at the moment
  790.         moveq    #64,d5                    
  791. .SkipV:        move.w    d5,scpc_oVolume(a3)            * Store volume
  792.         btst.b    #NCHB_Frequency,nch_Changed(a2)        * New frequency?
  793.         beq    .SkipF                    * No, use old
  794.         move.l    nch_Frequency(a2),d4            * Get new frequency
  795. .SkipF:        btst.b    #NCHB_Repeat,nch_Changed(a2)        * New loop values?
  796.         beq    .SkipR                    * No
  797.         move.l    nch_RepeatLength(a2),d2            * d2 = new loop length
  798.         move.l    nch_RepeatStart(a2),d3            * d3 = new loop pos
  799.         moveq    #2,d5                    * d5 = scratch
  800.         cmp.l    d5,d2                    * Loop only 1 Word or less?
  801.         bgt    .SkipR                    * No !
  802.         CLEAR    d2                    * Yes, don't use it.
  803. .SkipR:        btst.b    #NCHB_Sample,nch_Changed(a2)        * New sample value?
  804.         beq    .SkipS                    * Yes, get it
  805.         move.l    nch_SampleStart(a2),d1            * d1 = new sample pos
  806.         beq    .SkipS
  807.         move.l    nch_SampleLength(a2),d0            * d0 = new sample left
  808.         moveq    #2,d5
  809.         cmp.l    d5,d0
  810.         bgt    .SkipS
  811.         CLEAR    d0
  812.         CLEAR    d1
  813. .SkipS:        movem.l    d0-d4,scpc_oSampleLeft(a3)        * Store smppos,sz,loop,lpsz,freq
  814. .NextNew:    lea    scpc_SIZEOF(a3),a3
  815. .OnlyNew:    dbra    d7,.OnlyLoop
  816.         bra    .Exit
  817.  
  818. .Loop:        move.l    scpc_oExtChan(a3),d0            * Get NoteChannel struct
  819.         beq    .Exit
  820.         move.l    d0,a2                    * a2 = NoteChannel struct
  821.         cmpi.w    #NCHD_Ignore,nch_Stereo(a2)        * skip this channel ?
  822.         beq    .Nuke                    * yes !
  823.  
  824. .Volume:    move.w    scpc_oVolume(a6),d0            * Get old volume
  825.         btst.b    #NCHB_Volume,nch_Changed(a2)        * New volume?
  826.         beq    .VolOk                    * No
  827.         move.w    nch_Volume(a2),d0
  828.         cmp.w    #64,d0                    * Vol may not exceed
  829.         ble    .VolOk                    * 64 at the moment
  830.         moveq    #64,d0                    
  831. .VolOk:        move.w    d0,scpc_oVolume(a3)            * Store volume
  832.  
  833. .Frequency:    move.l    scpc_oFreq(a6),d4            * d4 = old frequency
  834.         btst.b    #NCHB_Frequency,nch_Changed(a2)        * New frequency?
  835.         beq    .Repeat                    * No, use old
  836.         move.l    nch_Frequency(a2),d4            * Get new frequency
  837.  
  838. .Repeat:    btst.b    #NCHB_Repeat,nch_Changed(a2)        * New loop values?
  839.         bne    .GetNewR                * Yes, get them
  840.         movem.l    scpc_oLoopSize(a6),d2-d3        * Get old loopsize and adr
  841.         bra    .RepOk
  842. .GetNewR:    move.l    nch_RepeatLength(a2),d2            * d2 = new loop length
  843.         move.l    nch_RepeatStart(a2),d3            * d3 = new loop pos
  844.         moveq    #2,d5                    * d5 = scratch
  845.         cmp.l    d5,d2                    * Loop only 1 Word or less?
  846.         bgt    .RepOk                    * No !
  847.         CLEAR    d2                    * Yes, don't use it.
  848.  
  849. .RepOk:        btst.b    #NCHB_Sample,nch_Changed(a2)        * New sample value?
  850.         bne    .GetNew                    * Yes, get it
  851. .GetPos:    move.l    d4,d5                    * Calc samples/interrupt
  852.         beq    .Nuke                    * No frequency => nuke channel
  853.         move.l    scpc_oSamplePos(a6),d1            * d1 = old sample pos
  854.         beq    .Nuke                    * None = nuke
  855.         divu.l    d6,d5                    * d5 = bytes played since last time
  856.         move.l    scpc_oSampleLeft(a6),d0            * d0 = old sample left
  857.         add.l    d5,d1                    * Calc new sample pos
  858.         sub.l    d5,d0                    * Calc new sample left
  859.         bgt    .Store                    * More remain
  860.         moveq    #2,d5
  861.         cmp.l    d5,d2                    * Loop exist?
  862.         ble    .Nuke                    * No
  863.         move.l    d0,d5                    * d5=neg bytes alr played in loop
  864.         move.l    d3,d1                    * SamplePos = LoopPos
  865.         move.l    d2,d0                    * SampleLeft = LoopSize
  866.         sub.l    d5,d1                    * Get current pos in loop
  867.         add.l    d5,d0                    * and bytes left in loop
  868.         bgt    .Store                    * Already 0? (short loops...)
  869.         neg.l    d0                    * Yes, d0=#of bytes alr played
  870.         divu.w    d2,d0                    * Divide that with loopsize to get
  871.         clr.w    d0                    * position offseted from start
  872.         swap    d0                    * d0 = remainder & bytes left
  873.         move.l    d3,d1                    * Get loopstart again
  874.         add.l    d0,d1                    * Add remainder
  875.         bra    .Store                    * And store...
  876. .GetNew:    move.l    nch_SampleStart(a2),d1            * d1 = new sample pos
  877.         beq    .Nuke
  878.         move.l    nch_SampleLength(a2),d0            * d0 = new sample left
  879.         moveq    #2,d5
  880.         cmp.l    d5,d0                    * New sample length good?
  881.         ble    .Nuke                    * No
  882.         btst.b    #NCHB_Repeat,nch_Changed(a2)        * New loop values supplied?
  883.         bne    .Store                    * Yes! Don't clear them
  884.         bra    .ClrLoop
  885.  
  886. .Nuke:        CLEAR    d0
  887.         CLEAR    d1
  888. .ClrLoop:    CLEAR    d2
  889.         CLEAR    d3
  890. .Store:        movem.l    d0-d4,scpc_oSampleLeft(a3)        * Store smppos,sz,loop,lpsz,freq
  891. .Next:        lea    scpc_SIZEOF(a3),a3
  892.         lea    scpc_SIZEOF(a6),a6
  893. .BegLoop:    dbra    d7,.Loop                * next channel
  894.  
  895. ;        DBUG    "Header updated OK\n",30
  896. .Exit:        and.b    #~(SCPHF_INVALID!SCPHF_UPDATED),scph_oFlags(a4) * Struct is no longer invalid or being updated
  897.  
  898. .Out:        movem.l    (sp)+,d2-d7/a2-a6
  899.         rts
  900.  
  901. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  902. *
  903. *        Quit DeliRave
  904.  
  905. dr_Exit:    DBUG    "** Entered dr_Exit.\n"
  906.         st    dr_oQuit(a5)                * Set the quit-flag
  907.         rts
  908.  
  909.  
  910. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  911. *
  912. *        Hide (quit) the RaveScope
  913.  
  914. dr_Disappear:    DBUG    "** Entered dr_Disappear.\n"        * Send killmsg to the RaveScope if
  915.         move.w    #RMSG_KILLRAVE,d0            * it is present. Return d0=0 if
  916.         jmp    _rh_WaitPutMsg                * it is not.
  917.  
  918.  
  919. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  920. *
  921. *        Show (start) the RaveScope if it is not running, else try to grab it
  922.  
  923. dr_Appear:    DBUG    "** Entered dr_Appear.\n"
  924.         move.l    rh_oRaveBase(a5),d0            * Do we have the ravescope?
  925.         bne    .Exit
  926.         jsr    _rh_GrabRave                * No, grab it!
  927.         CLEAR    d0
  928. .Exit:        rts
  929.  
  930.  
  931. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  932. *
  933. *        Stop the ravescope, clear all the scopeheaders & their channel structs
  934.  
  935. dr_EndPlay:    DBUG    "** Entered dr_EndPlay.\n"
  936.         clr.b    rh_oPlaying(a5)                * Clear our local play-flag
  937.         move.w    #RMSG_PLYHALTED,d0            * Tell the RaveScope (if we have)
  938.         jsr    _rh_SignalRave                * it) that our player is halted.
  939.         jsr    _rh_NukeChans                * Nuke all channels
  940.  
  941.         clr.l    dr_oNoteInfo(a5)            * Shutdown complete
  942.         moveq    #-1,d0                    * Set error
  943.         rts
  944.  
  945.  
  946. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  947. *
  948. *        Init Sound
  949.  
  950. dr_InitSnd:    rts
  951.         ;DBUG    "** dr_InitSnd: PLYACTIVE -> Rave\n"    * Tell the RaveScope (if it is
  952.         ;jmp    _rh_PlyActive                * present) that we're playing
  953.  
  954. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  955. *
  956. *        Remove Sound
  957.  
  958. dr_EndSnd:    DBUG    "** dr_EndSnd: PLYHALTED -> Rave\n"    * Tell the RaveScope (if we have
  959.         move.w    #RMSG_PLYHALTED,d0            * it) that we're not playing
  960.         clr.b    rh_oPlaying(a5)                * Clear our local play-flag
  961.         jmp    _rh_SignalRave
  962.  
  963. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  964. *
  965. *        Display-VBlank starten
  966.  
  967. dr_StartSnd:    DBUG    "** dr_InitSnd: PLYACTIVE -> Rave\n"    * Tell the RaveScope (if it is
  968.         jmp    _rh_PlyActive                * present) that we're playing
  969.  
  970. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  971. *
  972. *        Display-VBlank stoppen
  973.  
  974. dr_StopSnd:    DBUG    "** dr_StopSnd: PLYHALTED -> Rave\n"    * Tell the RaveScope (if we have
  975.         move.w    #RMSG_PLYHALTED,d0            * it) that we're not playing
  976.         clr.b    rh_oPlaying(a5)                * Clear our local play-flag
  977.         jmp    _rh_SignalRave
  978.  
  979. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  980. *
  981.         SECTION GenieDatas,Data
  982.  
  983.         include    include/delirave.i            * Global data struct defs
  984.  
  985. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  986. *
  987. *        Window texts
  988.  
  989. dr_ConfigEnv:    dc.b    'DeliConfig',0
  990. dr_ConfigPath:    dc.b    'PROGDIR:DeliConfig',0
  991.         dcb.b    120+1,0
  992. dr_ConfigFile:    dc.b    'RaveScope.prefs',0
  993. dr_DRCfgKey:    dc.b    " DELICONFIG",0
  994.  
  995. dr_TimerName:    dc.b    'timer.device',0
  996.  
  997.         even
  998.  
  999.  
  1000. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  1001. *
  1002. *
  1003.         SECTION DeliRaveBSS,BSS
  1004. *
  1005. *
  1006.  
  1007. dr_Data:    ds.b    DeliRave_SIZEOF                * DATA USED BY RS-TABLE
  1008.